package leetcode.bfs;

import leetcode.bfs.common.BFSUtils;
import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution1302 {
    public int deepestLeavesSum(TreeNode root) {
        return BFSUtils.deepestLeavesSum(root);
    }
}

public class leetcode1302 {
    public static void main(String[] args) {
        Solution1302 solution1302 = new Solution1302();
        Integer[] nums = {1, 2, 3, 4, 5, null, 6, 7, null, null, null, null, 8};
        Integer[] nums1 = {6, 7, 8, 2, 7, 1, 3, 9, null, 1, 4, null, null, null, 5};
        System.out.println(solution1302.deepestLeavesSum(TreeUtils.generateLeetcodeTree(nums)));
        System.out.println(solution1302.deepestLeavesSum(TreeUtils.generateLeetcodeTree(nums1)));
    }
}
